var btn = document.getElementById("login_btn");
var name;
btn.onclick = function () {
    name = document.getElementById("usrname").value;
    var passwd = document.getElementById("passwd").value;
    var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest对象
    var url = "index.html?username=" + name + "&" + "password=" + passwd; // 请求的URL
    xhr.open("GET", url, true);
    // 创建一个新的script元素  
    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) { // 请求完成  
            if (xhr.status === 200) { // 请求成功
                if (xhr.responseText.includes("login")) {
                    window.location.href = '/home.html';
                } else {
                    alert("用户名或密码错误");
                }
            }
        }
    }
    xhr.send();
}
var btn = document.getElementById("register_btn");
btn.onclick = function () {
    var name = document.getElementById("usrname").value;
    var passwd = document.getElementById("passwd").value;
    console.log(name);
    console.log(passwd);
}




